package com.example.chao.myphotosearch.view.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.example.chao.myphotosearch.R;
import com.example.chao.myphotosearch.model.DaggerLaunchComponent;
import com.example.chao.myphotosearch.presenter.LaunchPresenter;
import com.example.chao.myphotosearch.view.IView;

import javax.inject.Inject;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by chao on 2016/3/16.
 */
public class LaunchActivity extends AppCompatActivity implements IView<String> {

    @Inject
    LaunchPresenter launchPresenter;
    @Bind(R.id.skip_ad_btn)
    Button skipAdBtn;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.launch_activity);
        ButterKnife.bind(this);
        DaggerLaunchComponent.create().inject(this);
        launchPresenter.onCreate(this);
        skipAdBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                launchPresenter.onViewCreated();
            }
        });
    }

    @Override
    protected void onStart() {
        super.onStart();
//
    }


    @Override
    public void attachView(String data) {
        skipAdBtn.setText(data);
    }

    @Override
    public void detachView() {
        startActivity(new Intent(this, MainActivity.class));
        finish();
    }
}
